Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add python opener from rasterio 1.4 #1331

Merged
merged 2 commits into from
Feb 29, 2024
Merged

Add python opener from rasterio 1.4 #1331

merged 2 commits into from
Feb 29, 2024

Conversation

sgillies
Copy link
Member

@sgillies sgillies commented Feb 29, 2024

And supporting changes:

  • Modern _path module and updated usage
  • A setup.cfg for editable installs
  • A Dockerfile and Makefile for testing

See also rasterio/rasterio#3032
Resolves #1328

* Modern _path module and updated usage
* A setup.cfg for editable installs
* A Dockerfile and Makefile for testing

Resolves #1328
@sgillies sgillies added this to the 1.10 milestone Feb 29, 2024
@sgillies sgillies self-assigned this Feb 29, 2024
@sgillies sgillies changed the title Add rasterio's python opener from 1.4a1 Add rasterio's python opener from 1.4 Feb 29, 2024
@@ -0,0 +1,30 @@
ARG GDAL=ubuntu-small-3.6.4
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New default.

FROM gdal
COPY . .
RUN /venv/bin/python -m build -o wheels
RUN /venv/bin/python -m pip install --no-index -f wheels fiona[test]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's been good to have a chance to revisit the Dockerfile. This is the way to build and install packages now.

setup.cfg Show resolved Hide resolved
@sgillies sgillies marked this pull request as ready for review February 29, 2024 15:01
@sgillies sgillies changed the title Add rasterio's python opener from 1.4 Add python opener from rasterio 1.4 Feb 29, 2024
@sgillies
Copy link
Member Author

The test failures are with Python 3.7 and 3.8, which are being left behind by Numpy. Fiona 1.10 will drop support for them, too.

@sgillies sgillies merged commit 5a514bd into master Feb 29, 2024
4 of 9 checks passed
@sgillies sgillies deleted the issue1328 branch February 29, 2024 17:42
@sgillies sgillies mentioned this pull request Feb 29, 2024
@@ -41,6 +35,7 @@ dependencies = [
"click-plugins>=1.0",
"cligj>=0.5",
'importlib-metadata;python_version<"3.10"',
"numpy>=1.25,<2",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not needed to require a numpy 1.25 as a minimum version. The goal of building with a minimum version of 1.25 is that this ensures it also runs with older numpys
(in contrast to older versions of numpy, where building with that specific version meant that the wheels were only compatible with that version or up, hence the use of "oldest-supported-numpy" for wheel building)

See https://numpy.org/doc/stable/release/1.25.0-notes.html#compiling-against-the-numpy-c-api-is-now-backwards-compatible-by-default in the 1.25 release notes, and https://numpy.org/doc/stable/dev/depending_on_numpy.html#build-time-dependency

Comment on lines -4 to +2
"oldest-supported-numpy",
"setuptools>=67.8",
"wheel",
]
requires = ["setuptools>=67.8", "cython~=3.0.2", "numpy>=1.25,<2"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another question, seeing numpy included here: do you know for what reason fiona actually did have a build requirement on numpy before? A search in the codebase doesn't actually show any use of numpy (before this PR)

It seems this was brought in with 37da85d, which copied some code from rasterio (and rasterio indeed depends on numpy, but AFAIK Fiona does not?)

cdef size_t pyopener_write(void *pFile, void *pBuffer, size_t nSize, size_t nCount) with gil:
cdef object file_obj = <object>pFile
buffer_len = nSize * nCount
cdef np.uint8_t [:] buff_view = <np.uint8_t[:buffer_len]>pBuffer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can see, this is the only use of numpy in this PR. I think this could be easily avoided by using a builtin cython type instead of a numpy type. Something like unsigned char instead of np.uint8_t

That would also avoid having to add numpy as a build dependency to start with?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jorisvandenbossche yes, I'll definitely look into removing the hard numpy requirement before the next pre-release.

@@ -60,7 +62,7 @@
_remove,
_remove_layer,
)
from fiona.path import ParsedPath, parse_path, vsi_path
from fiona._path import _ParsedPath, _UnparsedPath, _parse_path, _vsi_path
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, I see you added a deprecation warning inside the fiona.path module. But the above change directly breaks code that was using those functions from top-level fiona instead of from fiona.path

We are running into some issues with this in geopandas: geopandas/geopandas#3207

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I commented at geopandas/geopandas#3207. Fiona's path module and methods are only public by accident. Other projects shouldn't be coupled to fiona's internals, which are full of weird details. Removing this coupling between geopandas and fiona shouldn't be hard and I'm happy to help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bring over Rasterio's python opener
2 participants